package com.zfl.utils;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;


public class PasswordUtils {
    private static final BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();

    // 加密密码（注册/修改密码时用）
    public static String encrypt(String rawPassword) {
        return encoder.encode(rawPassword);
    }

    // 比对密码（登录时用：明文密码 vs 数据库加密密码）
    public static boolean matches(String rawPassword, String encodedPassword) {
        return encoder.matches(rawPassword, encodedPassword);
    }
}